package com.lhhu.demo.controller;

import com.lhhu.demo.bean.BookMessage;
import com.lhhu.demo.service.SearchService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @Auther 虎
 * @Data 2021/3/21 20:42
 * @Version 1.0
 */
@RestController
public class SearchController {
    @Autowired
    private SearchService searchService;

    @GetMapping("/getBookByMoneyUp")
    public List<BookMessage> getBookByMoneyUp(String bookName){
        return searchService.getBookByMoneyUp(bookName);
    }

    @GetMapping("/getBookByMoneyDown")
    public List<BookMessage> getBookByMoneyDown(String bookName){
        return searchService.getBookByMoneyDown(bookName);
    }

    @GetMapping("/getBookByDiscountUp")
    public List<BookMessage> getBookByDiscountUp(String bookName){
        return searchService.getBookByDiscountUp(bookName);
    }

    @GetMapping("/getBookByDiscountDown")
    public List<BookMessage> getBookByDiscountDown(String bookName){
        return searchService.getBookByDiscountDown(bookName);
    }

    @GetMapping("/getBookByCategoryAndOther")
    public List<BookMessage> getBookByCategoryAndOther(String bookCategoryId,int currentIndex,int status){
        if(currentIndex ==1){
            if(status==1)return searchService.getBookByCategoryAndDiscountUp(bookCategoryId);
            else return searchService.getBookByCategoryAndDiscountDown(bookCategoryId);
        }else{
            if(status==1)return searchService.getBookByCategoryAndMoneyUp(bookCategoryId);
            else return searchService.getBookByCategoryAndMoneyDown(bookCategoryId);
        }
    }
}
